import request from './request'
import qs from 'qs'

export const loginApi = params => request.post('/admin/login', params)

export const getUserInfo = () => request.get('/admin/info')

export const getAdminList = params => request.get('/admin/list', { params })

export const updateStauts = params => request.post(`/admin/updateStatus/${params.id}?status=${params.status}`)

export const addUser = params => request.post('/admin/register', params)

export const getUserInfoById = id => request.get(`/admin/${id}`)

export const updateUserInfo = params => request.post(`/admin/update/${params.id}`, params)

export const getUserRolesById = id => request.get(`/admin/role/${id}`)

export const getAllRoles = () => request.get('/role/listAll')

export const getRolesByPage = params => request.get('/role/list', { params })

export const updateAdminRole = params => request.post('/admin/role/update', qs.stringify(params))

export const createRole = params => request.post('/role/create', params)

export const updateRoleStatus = params => request.post(`/role/updateStatus/${params.id}?status=${params.status}`)

export const getAllResources = () => request.get('/resource/listAll')

export const getAllResourcesCate = () => request.get('/resourceCategory/listAll')

export const getResurceByRoleId = id => request.get(`/role/listResource/${id}`)

export const updateRoleResource = params => request.post('/role/allocResource', qs.stringify(params))